package cn.com.ccxe.core.db.util;

import cn.com.ccxe.core.entity.ArticleLink;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;


public final class ArticleLinkTupleBinding extends TupleBinding<ArticleLink> {

	@Override
	public ArticleLink entryToObject(TupleInput input) {
		ArticleLink webURL = new ArticleLink();
		webURL.setPath(input.readString());
		webURL.setUpdateTime(input.readDouble());
		webURL.setFetchTime(input.readInt());
		webURL.setStatusCode(input.readInt());
		webURL.setMD5Value(input.readString());
		webURL.setTitle(input.readString());
		webURL.setModuleId(input.readInt());
		return webURL;
	}

	@Override
	public void objectToEntry(ArticleLink url, TupleOutput output) {		
		output.writeString(url.getPath());
		output.writeDouble(url.getUpdateTime());
		output.writeInt(url.getFetchTime());
		output.writeInt(url.getStatusCode());
		output.writeString(url.getMD5Value());
		output.writeString(url.getTitle());
		output.writeInt(url.getModuleId());
	}
}
